/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 阿宾
 * Date: 2024-05-10
 * Time: 11:53
 */
class Student{
    //普通成员变量
    private String name;
    private int age;
    //静态成员变量
    public static String classRoom;

    //实例代码块,用于初始化普通成员变量
    {
        this.name = "小明";
        this.age = 18;
        System.out.println("实例化代码块");
    }
    /*//静态代码块，用于初始化静态成员变量
    static {
        classRoom = "111";
        System.out.println("静态代码块1");
    }
    static {
        classRoom = "222";
        System.out.println("静态代码块2");
    }*/

    //@Override
    /*public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }*/

    //普通成员方法
    public void show(){
        System.out.println("姓名："+this.name+"年龄："+this.age);
    }

    //构造方法
    public Student(){
        System.out.println("定义一个不带参数的构造方法");
    }
}

public class Test03 {
    public static void main(String[] args) {
        Student stu = new Student();
        stu.show();
        Student student = new Student();
        student.show();
    }
}
